<template>
  <div>
    <el-table :data="dataList" stripe style="width: 100%" border>
      <el-table-column prop="prefix_custom" label="前缀">
        <template slot-scope="scope">
          <el-input v-model="scope.row.prefix_custom"></el-input>
        </template>
      </el-table-column>
      <el-table-column prop="date" label="日期">
        <template slot-scope="scope">
          <el-select v-model="scope.row.date" placeholder="请选择日期">
            <el-option  label="年" value="1">
            </el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column prop="serial_number" label="序号"> </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {
  getRuleSerialNumber,
  createColor,
  delColor,
} from "@/api/product/index";
export default {
  data() {
    return {
      dataList: [],
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    del_product(row) {
      console.log("ww");
      delColor({
        id: row.id,
        is_del: 1,
      }).then((res) => {
        if (res.code == 200) {
          this.isProduct = false;
          this.$message.success("提交成功");
          this.getlist();
        }
      });
    },
    getlist() {
      getRuleSerialNumber().then((res) => {
        if (res.code == 200) {
          this.dataList.push(res.data);
          console.log(this.dataList);
        }
      });
    },
    set_product(row) {
      this.ruleForm.color = row.color;
      this.ruleForm.id = row.id;
      this.title = "颜色编辑";
      this.isProduct = true;
    },
    add_color() {
      this.title = "新增颜色";
      this.isProduct = true;
      this.$nextTick(function () {
        this.$refs.ruleForm.resetFields();
      });
    },
    submitadd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          createColor(this.ruleForm).then((res) => {
            if (res.code == 200) {
              this.isProduct = false;
              this.$message.success("提交成功");
              this.getlist();
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleSizeChange(val) {
      console.log(val);
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.page = val;
      this.getlist();
    },
    prev() {
      this.pagination.page = this.pagination.page - 1;
      this.getlist();
    },
    next() {
      console.log("ss");
      this.pagination.page = this.pagination.page + 1;
      this.getlist();
    },
    clolr_click() {
      getColorList({ color: this.color }).then((res) => {
        if (res.code == 200) {
          this.dataList = res.data.data;
          this.total = res.data.total;
        }
      });
    },
  },
};
</script>

<style></style>
